package com.chaos.system.controller;

import com.chaos.system.api.data.UserSessionKeyData;
import com.chaos.system.service.UserSessionKeyService;
import com.chaos.framework.model.dto.ID;
import com.chaos.framework.model.dto.page.PageQueryDto;
import com.chaos.framework.model.dto.result.data.BooleanResult;
import com.chaos.framework.model.dto.result.data.DataResult;
import com.chaos.framework.model.dto.result.list.ListResult;
import com.chaos.framework.model.dto.result.page.PageResult;
import com.chaos.framework.starter.base.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jacky
 * @since 2025-07-03
 */
@RestController
@AllArgsConstructor
@RequestMapping(value = {"/userSessionKey"})
@Tag(name = "SessionKey", description = "SessionKey")
public class UserSessionKeyController extends BaseController<UserSessionKeyData> {

    private final UserSessionKeyService userSessionKeyService;

    @PostMapping("/one.admin")
    @ApiOperation(value = "SessionKey详情", httpMethod = "POST")
    public DataResult<UserSessionKeyData> one(@RequestBody ID data) {
        return dataResult(userSessionKeyService.selectByID(data));
    }

    @PostMapping("/list.admin")
    @ApiOperation(value = "SessionKey列表", httpMethod = "POST")
    public ListResult<UserSessionKeyData> list(@RequestBody UserSessionKeyData data) {
        return listResult(userSessionKeyService.selectByData(data));
    }

    @PostMapping("/page.admin")
    @ApiOperation(value = "SessionKey分页", httpMethod = "POST")
    public PageResult<UserSessionKeyData> page(@RequestBody PageQueryDto<UserSessionKeyData> data) {
        return pageResult(userSessionKeyService.selectByPage(data));
    }

    @PostMapping("/add.admin")
    @ApiOperation(value = "新增SessionKey", httpMethod = "POST")
    public DataResult<ID> add(@RequestBody UserSessionKeyData data) {
        return dataResult(userSessionKeyService.insertModel(data));
    }

    @PostMapping("/update.admin")
    @ApiOperation(value = "编辑SessionKey", httpMethod = "POST")
    public BooleanResult update(@RequestBody UserSessionKeyData data) {
        return booleanResult(userSessionKeyService.updateModelByID(data));
    }

    @PostMapping("/delete.admin")
    @ApiOperation(value = "删除SessionKey", httpMethod = "POST")
    public BooleanResult delete(@RequestBody ID data) {
        return booleanResult(userSessionKeyService.deleteModel(data));
    }

}
